<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{$Think.config.site.title} - 商户管理</title>
    <meta name="keywords" content="{$Think.config.site.keywords}">
    <meta name="description" content="{$Think.config.site.description}">
    <link href="{$Think.config.site.resource_url}css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/animate.min.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/plugins/chosen/chosen.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/style.min.css?v=4.0.0" rel="stylesheet">
</head>

<body class="">
    <div class="wrapper wrapper-content animated fadeInRight">
    <form method="post" class="form-horizontal" action="" id="myformdata" enctype="multipart/form-data">  
      <div class="row">          
          <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                            <div class="form-group">
                                <label class="col-sm-5 control-label">商铺名称</label>
                                <div class="col-sm-7">
                                    <input type="text" class="form-control" name="name" id="name"  placeholder="输入商铺名称">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-5 control-label">电话</label>
                                <div class="col-sm-7">
                                    <input type="text" class="form-control" name="phone" di="phone"  placeholder="输入电话号码">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-5 control-label">选择机柜ID</label>
                                <div class="col-sm-7">
                                    <select data-placeholder="请选择机柜ID..." class="chosen-select  form-control" name="cabinet_id" style="width:350px;" tabindex="2" required>
                                        <option value="">请选择机柜ID</option>
                                        {volist name="list" id="vo"}
                                        <option value="{$vo.id}">{$vo.cabinet_id}</option>
                                        {/volist}
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-5 control-label">商铺图片</label>
                                <div class="col-sm-7">
                                    <input type="file" class="" name="picture" id="picture" placeholder="上传图片">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-5 control-label" >所在区域</label>
                                <div class="col-sm-7">
                                    <input type="text" class="form-control" id="area" name="area" value="" placeholder="输入所在区域">
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <label class="col-sm-5 control-label">详细地址</label>
                                <div class="col-sm-7">
                                   <input type="text" class="form-control" id="addr" name="addr" value="" placeholder="输入详细地址">
                                </div>
                            </div>
                            <div class="form-group">
                               <label class="col-sm-5 control-label">经度</label>
                                <div class="col-sm-7">
                                    <input type="text" class="form-control" id="longitude" name="longitude" value="" placeholder="输入经度">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-5 control-label">纬度</label>
                                <div class="col-sm-7">
                                    <input type="text" class="form-control" id="latitude" name="latitude" value="" placeholder="输入纬度">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-5 control-label">营业时间</label>
                                <div class="col-sm-7">
                                    <input type="time" class="form-control layer-date" required="" aria-required="true" style="width:110px" name="shopstart" value="" placeholder="输入开始时间"><span class=""> ~ </span><input type="time" style="width:110px" class="form-control layer-date" name="shopend" required="" aria-required="true" value="" placeholder="输入结束时间">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-5 control-label">人均消费</label>
                                <div class="col-sm-7">
                                    <input type="text" class="form-control" name="averageprice" id="averageprice" placeholder="输入人均消费">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-5 control-label">佣金比例</label>
                                <div class="col-sm-7">
                                    <input type="text" class="form-control" id="brokerage" name="brokerage" value="" placeholder="输入佣金比例">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-sm-12">
                    <div class="form-group">
                        <div class="col-sm-5 col-sm-offset-5">
                            　　<input type="button" class="btn btn-primary" value="提 交" id="onbtn">
                        </div>
                    </div>
                </div>
        </div>
    </form>
    </div>

    <script src="{$Think.config.site.resource_url}js/jquery.min.js?v=2.1.4"></script>
    <script src="{$Think.config.site.resource_url}js/bootstrap.min.js?v=3.3.5"></script>
    <script src="{$Think.config.site.resource_url}js/content.min.js?v=1.0.0"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/validate/jquery.validate.min.js"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/validate/messages_zh.min.js"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/chosen/chosen.jquery.js"></script>
  <script src="{$Think.config.site.resource_url}js/plugins/layer/layer.js"></script>
</body>

</html>
<script>
$(document).ready(function(){ 
$('.chosen-select').chosen(); 
	$('#onbtn').click(function(){
        var name = $('#name').val();
        var phone = $('#phone').val();
        var area = $('#area').val();
        if(name==''){
            $('#name').focus();
            return false;
        }
        if(phone==''){
            $('#phone').focus();
            return false;
        }
        if(area==''){
            $('#area').focus();
            return false;
        }

		//var fomrData = $("#myformdata").serialize();
        var formData = new FormData($( "#myformdata" )[0]);
		var action = 'add';
		$.ajax({
			type : 'POST',
			url : '<?php echo \think\Request::instance()->root(); ?>/ausagent/Seller/'+action,
			data: formData, 
            async: false, 
            cache: false, 
            contentType: false, 
            processData: false, 
			success : function(result) {
                //layer.close(layer1);
                if(0 === result.code) {
                    layer.msg(result.msg, {icon: 1});
                    parent.location.reload();
                }  else  {
                    //删除失败
                    layer.msg(result.msg, {icon: 5});
                }
            },
            error : function(){
                res = false;
                layer.msg('服务器错误！请稍后重试', {icon: 2});
            }
		})
	});
})
</script>

<script src="{$Think.config.site.resource_url}js/plugins/layer/laydate/laydate.js"></script>
    <script>
        //外部js调用
        laydate({
            elem: '#hello', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
            event: 'focus' //响应事件。如果没有传入event，则按照默认的click
        });

        //日期范围限制
        var start = {
            elem: '#start',
            format: 'YYYY/MM/DD hh:mm:ss',
            min: laydate.now(), //设定最小日期为当前日期
            max: '2099-06-16 23:59:59', //最大日期
            istime: true,
            istoday: false,
            choose: function (datas) {
                end.min = datas; //开始日选好后，重置结束日的最小日期
                end.start = datas //将结束日的初始值设定为开始日
            }
        };
        var end = {
            elem: '#end',
            format: 'YYYY/MM/DD hh:mm:ss',
            min: laydate.now(),
            max: '2099-06-16 23:59:59',
            istime: true,
            istoday: false,
            choose: function (datas) {
                start.max = datas; //结束日选好后，重置开始日的最大日期
            }
        };
        laydate(start);
        laydate(end);
    </script>